package bbb;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class ParserUtils {

	public static BallInfo parse(String info) {
		String[] infos = info.split(" ");
		if (infos != null && infos.length == 9) {
			BallInfo bi = new BallInfo();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			try {
				bi.setDate(sdf.parse(infos[0]));
				bi.setCode(infos[1]);
				bi.setRed1(Integer.parseInt(infos[2]));
				bi.setRed2(Integer.parseInt(infos[3]));
				bi.setRed3(Integer.parseInt(infos[4]));
				bi.setRed4(Integer.parseInt(infos[5]));
				bi.setRed5(Integer.parseInt(infos[6]));
				bi.setRed6(Integer.parseInt(infos[7]));
				bi.setBlue(Integer.parseInt(infos[8]));
			} catch (ParseException e) {
				e.printStackTrace();
				return null;
			}
			return bi;
		}
		return null;
	}

	public static void main(String[] args) {
		System.out.println(parse("2014-01-28 2014012 01 08 11 19 21 24 08"));
//		BallMap.loadData("C:\\Users\\Administrator\\Desktop\\双色球\\1.txt");
	}
}
